Implement callback in libjeeps for waypoint output, use that for status
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 16 Jan 2004 14:41:53 +0000 (14:41 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Fri, 16 Jan 2004 14:41:53 +0000 (14:41 +0000)
in garmin.c

gpsbabel/garmin.c
gpsbabel/jeeps/gpsapp.c
gpsbabel/jeeps/gpsapp.h
gpsbabel/jeeps/gpscom.c
gpsbabel/jeeps/gpscom.h

index 51d3beb1f3c4bbd634b1ac00796b6b3380bdea36..f1f4bf690990934c9efb004f89d387285cbb7c3f 100644 (file)
@@ -304,6 +304,17 @@ sane_GPS_Way_New(void)
 
        return way;
 }
+static int 
+waypt_write_cb(GPS_PWay *way)
+{
+       static int i;
+
+       if (global_opts.verbose_status) {
+               fprintf(stdout, "%d\r", ++i*100/waypt_count());
+               fflush(stdout);
+       }
+       return 0;
+}
 
 static void
 waypoint_write(void)
@@ -350,13 +361,9 @@ waypoint_write(void)
                if (wpt->altitude != unknown_alt) {
                        way[i]->alt = wpt->altitude;
                }
-               if (global_opts.verbose_status) {
-                       fprintf(stdout, "%d\r", i*100/n);
-                       fflush(stdout);
-               }
                i++;
        }
-       if ((ret = GPS_Command_Send_Waypoint(portname, way, n)) < 0) {
+       if ((ret = GPS_Command_Send_Waypoint(portname, way, n, waypt_write_cb)) < 0) {
                fatal(MYNAME ":communication error sending wayoints..\n");
        }
 
@@ -365,6 +372,7 @@ waypoint_write(void)
        }
        if (global_opts.verbose_status) {
                fprintf(stdout, "\r\n");
+               fflush(stdout);
        }
        xfree(way);
 }
index 6fff831577911bb894eb30d62c39cef6c86181c7..f75b767deef9455cc7218a8724de268de9210f6e 100644 (file)
@@ -27,7 +27,6 @@
 #include <time.h>
 #include <stdlib.h>
 
-
 static int32    GPS_A000(const char *port);
 static void   GPS_A001(GPS_PPacket packet);
 
@@ -695,7 +694,7 @@ int32 GPS_A100_Get(const char *port, GPS_PWay **way)
 **
 ** @return [int32] success
 ************************************************************************/
-int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n)
+int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n, int (*cb)())
 {
     UC data[GPS_ARB_LEN];
     int32 fd;
@@ -724,6 +723,11 @@ int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n)
 
     for(i=0;i<n;++i)
     {
+        if (cb) {
+               if (cb(way[i]))
+                       break;
+       }
+
        switch(gps_waypt_type)
        {
        case pD100:
@@ -788,7 +792,7 @@ int32 GPS_A100_Send(const char *port, GPS_PWay *way, int32 n)
            return gps_errno;
        }
     }
-    
+
     GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Transfer_Wpt);
     GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Xfer_Cmplt,
                    data,2);
index 11889530367afb049ec71b2892f82da058b417d4..5f27450a39a27d02fa5b3c20097a651573baf9d9 100644 (file)
@@ -12,7 +12,7 @@ extern "C"
 int32  GPS_Init(const char *port);
 
 int32  GPS_A100_Get(const char *port, GPS_PWay **way);
-int32  GPS_A100_Send(const char *port, GPS_PWay *way, int32 n);
+int32  GPS_A100_Send(const char *port, GPS_PWay *way, int32 n, int (*cb)(GPS_PWay *));
 
 int32  GPS_A200_Get(const char *port, GPS_PWay **way);
 int32  GPS_A201_Get(const char *port, GPS_PWay **way);
index d1d07d704459d665f80076491b743cbae8e98049..7ac611aea777fdeee4156c57cd2d859f76eef0e1 100644 (file)
@@ -109,14 +109,14 @@ int32 GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way)
 ** @return [int32] success
 ************************************************************************/
 
-int32 GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n)
+int32 GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n, int (*cb)())
 {
     int32 ret=0;
 
     switch(gps_waypt_transfer)
     {
     case pA100:
-       ret = GPS_A100_Send(port, way, n);
+       ret = GPS_A100_Send(port, way, n, cb);
        break;
     default:
        GPS_Error("Send_Waypoint: Unknown waypoint protocol");
index ba1c36f09a2b4e2681e254b62d539ac383589ff9..90c0cba5218288987a8a6eb6389222ece3129771 100644 (file)
@@ -29,7 +29,7 @@ int32  GPS_Command_Get_Track(const char *port, GPS_PTrack **trk);
 int32  GPS_Command_Send_Track(const char *port, GPS_PTrack *trk, int32 n);
 
 int32  GPS_Command_Get_Waypoint(const char *port, GPS_PWay **way);
-int32  GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n);
+int32  GPS_Command_Send_Waypoint(const char *port, GPS_PWay *way, int32 n, int (*cb)());
 
 int32  GPS_Command_Get_Proximity(const char *port, GPS_PWay **way);
 int32  GPS_Command_Send_Proximity(const char *port, GPS_PWay *way, int32 n);